package jsyf.oa.web.intentCustomerReport;

import com.alibaba.fastjson.JSONObject;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import jsyf.com.util.BaseUtils;
import jsyf.com.util.ResponseUtils;
import jsyf.oa.facade.intentCustomerReport.IntentCustomerReportFacade;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Created by 92852 on 2018/8/7.
 */
@Api(value = "意向客户报表接口", description = "意向客户报表接口")
@Controller
@RequestMapping("/intentCustomerReport")
public class IntentCustomerReportController {
    @Resource
    private IntentCustomerReportFacade intentCustomerReportFacade;

    @ResponseBody
    @RequestMapping(value = "/getGroupByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取集团意向客户报表",
            notes = "获取集团意向客户报表",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:''}", dataType = "String", paramType = "body")
    public void getIntentCustomerList(HttpServletResponse response, @RequestBody String jsonData) {
        List<JSONObject> jsonObjectList = intentCustomerReportFacade.getGroupByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessArrHourTimeRespond(jsonObjectList));
    }
    @ResponseBody
    @RequestMapping(value = "/getAllCustomersByCompanyId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取集团下公司全部意向客户",
            notes = "获取集团下公司全部意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{companyId:'',key:'',allNum:''}", dataType = "String", paramType = "body")
    public void getAllCustomersByCompanyId(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonObjectList = intentCustomerReportFacade.getAllCustomersByCompanyId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjHourRespond(jsonObjectList));
    }

    @ResponseBody
    @RequestMapping(value = "/getPersonalByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取个人意向客户",
            notes = "获取个人意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'',key:'',}", dataType = "String", paramType = "body")
    public void getPersonalByUserId(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonObjectList = intentCustomerReportFacade.getPersonalByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjHourRespond(jsonObjectList));
    }

    @ResponseBody
    @RequestMapping(value = "/getBigRegionByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取大区意向客户",
            notes = "获取大区意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'',key:'',}", dataType = "String", paramType = "body")
    public void getBigRegionByUserId(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonObjectList = intentCustomerReportFacade.getBigRegionByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjHourRespond(jsonObjectList));
    }

    @ResponseBody
    @RequestMapping(value = "/getCompanyByUserId.json", method = RequestMethod.POST)
    @ApiOperation(
            value = "获取公司意向客户",
            notes = "获取公司意向客户",
            httpMethod = "POST",
            produces = MediaType.APPLICATION_JSON_VALUE)
    @ApiImplicitParam(name = "jsonData", value = "{userId:'',key:'',}", dataType = "String", paramType = "body")
    public void getCompanyByUserId(HttpServletResponse response, @RequestBody String jsonData) {
        JSONObject jsonObjectList = intentCustomerReportFacade.getCompanyByUserId(jsonData);
        ResponseUtils.putJsonResponse(response, BaseUtils.succsessObjHourRespond(jsonObjectList));
    }



}
